<?php 
/**
 * [CT 时间转换]
 * @Author   Xuebingsi
 * @DateTime 2017-03-08T08:56:40+0800
 * @param    [int]                   $time [时间戳]
 */
function CT($time)
{
    $diff = time()-$time;
    if($diff<60){
        return "刚刚";
    }elseif($diff<3600){
        return round($diff/60)."分钟之前";
    }elseif($diff<86400){
        return round($diff/60/60)."小时之前";
    }elseif($diff<(86400*7)){
        return round($diff/86400)."天之前";
    }else{
        return date('Y-m-d H:i:s',$time);
    }
}


//发邮件
function linemail($email,$title,$content)
{
	//require 'PHPMailerAutoload.php';                    // 传统的引入方式

	Vendor('PHPMailer.PHPMailerAutoload');				  // TP自动加载Vendor

	$mail = new PHPMailer;

	//var_dump($mail);exit; //查看引入是否正确,实例化PHPMaile类正确能得到对象

	//$mail->SMTPDebug = 3;                               // Enable verbose debug output

	//各种配置
	$mail->isSMTP();                                      // 使用的是SMTP模式
	$mail->Host = 'smtp.qq.com';                          // 邮件服务器地址 调用QQ接收邮箱地址
	$mail->SMTPAuth = true;                               // Enable SMTP authentication 是否验证
	$mail->Username = '641166354@qq.com';                 // SMTP username 登陆邮箱验证-我的账号
	$mail->Password = 'eappnrypmzivbdeh';                 // SMTP password 成功开启POP3/SMTP服务时拿到的密码
	$mail->SMTPSecure = 'ssl';                            // Enable TLS encryption, `ssl` also accepted  qq邮箱用的是ssl协议
	$mail->Port = 465;                                    // TCP port to connect to  qq邮箱的端口465

	$mail->setFrom('641166354@qq.com', 'Lin-Heaven');	  // setFrom谁发的
	$mail->addAddress($email, '接收人');                  // Add a recipient 发给谁
	//$mail->addAddress('ellen@example.com');               // Name is optional 可同时发给多人
	//$mail->addReplyTo('info@example.com', 'Information'); // 收到邮件可回复给谁
	//$mail->addCC('cc@example.com');						// 发邮件的抄送、密送等
	//$mail->addBCC('bcc@example.com');

	//$mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments  发邮箱插件附件
	//$mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name    发邮箱插件附件
	$mail->isHTML(true);                                  // Set email format to HTML 内容里面是否包含html标签

	$mail->Subject = $title;               // Subject项目  邮件的标题
	$mail->Body    = $content;             //邮件内容
	//$mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; //打不开邮件的提示内容-意义不大

	if(!$mail->send()) {
	    echo 'Message could not be sent.';
	    echo 'Mailer Error: ' . $mail->ErrorInfo;
	} else {
	    echo 'Message has been sent';
	}


}


function HLlogin()
{
	
    Vendor('QQConnect.API.qqConnectAPI');
    $qc = new \QC(); // \全局类
    //var_dump($qc);exit;

    $qc->qq_login();
}

function getOpenid()
{
	//var_dump($_GET);
    Vendor('QQConnect.API.qqConnectAPI');
    $qc = new \QC(); // \全局类
    //var_dump($qc);exit;

    $qc->qq_callback();

    //回调ID
    return $qc->get_openid();
    //var_dump($openid);   75ADA8330886BEE4DEA2B1248A7E0D0E
    
}

//获取用户信息
function getUserInfo()
{	
	Vendor('QQConnect.API.qqConnectAPI');
	$qc = new \QC();
	return $qc->get_user_info();
	
}







 ?>